package org.gd.hellojavacore.tests;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: user
 * Date: 4/30/13
 * Time: 2:11 PM
 * To change this template use File | Settings | File Templates.
 */
public class StringBuilderTest {

    public static void main(String...str) {
        String cardNumber = "5577212708985646";

        ArrayList<String> fields = new ArrayList<String>();
        fields.add("OKPO");
        fields.add("ruLName");
        fields.add("ruFName");
        fields.add("ruMName");
        fields.add("CountryRes");
        fields.add("Id");

        StringBuilder req = new StringBuilder();
        req.append("<?xml version='1.0' encoding='UTF-8'?>").append("\n");

        req.append("<doc>").append("\n");
        req.append("<r cntr='UA' key='13' t='INF_NEW'>").append("\n");
        req.append("<i Pan=\"").append(cardNumber).append("\" />").append("\n");
        req.append("<o>").append("\n");
        for (String field : fields) {
            req.append("\t").append("<").append(field).append("/>").append("\n");
        }
        req.append("</o>").append("\n");
        req.append("</r>").append("\n");
        req.append("</doc>").append("\n");

        System.out.printf("\n%s\n", req.toString());
    }
}
